<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

	if ( !function_exists('log_activity'))
	{
			function log_activity($log, $scope='', $type='', $logged_by='') {
					$_ci = & get_instance();
					$_ci->load->database(); 
					$dmc = $_ci->config->item('datamapper');
					$opts = read_options('logging_status', 'OBJECT'); 
					if($opts->logging_status=='enabled')
					{
							$_ci->db->insert(@$dmc['prefix'] . 'logs', array(
									'log'=>trim($_ci->security->xss_clean($log)),
									'scope'=>trim($_ci->security->xss_clean($scope)),
									'type'=>trim($_ci->security->xss_clean($type)),
									'logged_by'=>trim($_ci->security->xss_clean($logged_by)),
									'l_added'=>time()
							)); 
					}
			}
	}
	
	if ( !function_exists('read_sys_logs'))
	{
			function read_sys_logs($scope='', $type='', $logged_by='') {
					$_ci = & get_instance();
					$_ci->load->database(); 
					$dmc = $_ci->config->item('datamapper');
					if($scope!='') 		$_ci->db->where('scope', trim($_ci->security->xss_clean($scope)));
					if($type!='') 		$_ci->db->where('type', trim($_ci->security->xss_clean($type)));
					if($logged_by!='') 	$_ci->db->where('logged_by', trim($_ci->security->xss_clean($logged_by)));
					$_ci->db->order_by('id', "desc");
					$query 				= $_ci->db->get(@$dmc['prefix'] . 'logs');
					return $query;
			}
	}
	
/* End of file logs_helper.php */
/* Location: ./application/helpers/logs_helper.php */